<template>
    <view class="" :style="[$em.$getThemeStyle(['bg-color--1'])]">
		<em-header-inset></em-header-inset>
		<em-list-mp :rowlist.sync="list1" :api="api1" :params="params1" :fixed="true" :autofresh="true" :method="'GET'" ref="list1" emptyText="没有更多了">
			<template v-slot="{list}">
				<!-- <em-header-inset></em-header-inset> -->
				<edit-box class="liked-scale-animation" @published="onpPublished"></edit-box>
				<view v-for="(item, index) in list" :key="item.id" class="liked-scale-animation">
					<item-wrap :item.sync="item" @delAction="delAction"></item-wrap>
				</view>
			</template>
		</em-list-mp>
    </view>
</template>

<script>
  import itemWrap from '@/pages/circle/components/item-wrap.vue';
  import editBox from '@/pages/circle/components/edit-box.vue';
  import { mapState } from 'vuex'
	let app = {}
	// #ifdef MP-WEIXIN || MP-KUAISHOU
	app = getApp({ allowDefault: true}).$vm
	// #endif
	// #ifdef APP-PLUS || H5
	app = getApp({allowDefault: true})
	// #endif
	

  export default {
	 components: {
	   itemWrap,
	   editBox
	 },
    data() {
      return {
		  api1:"/api/circle/getlistRecommend",
		  params1:{
		  	time:0,
		  },
		  params_ext1:{},
		  list1:[],
	  }
    },
    computed: {
		...mapState([
		'systemInfo', 
		'config',
		'userInfo'
		]),
      pageStyles() {
        return {
          wrap: app.$getThemeStyle(['bg-color--1'])
        }
      },
	  headerStyles() {
	    return {
	      wrap: app.$getThemeStyle(['bg-color-1',]),
	      title: app.$getThemeStyle(['color-1'])
	    }
	  },
	  headerLeftBtns() {
	    return [{
	  			iconUnicode: '\uea64',
	  			styles: {
	  			  btn: app.$getThemeStyle(['bg-color-102']),
	  			  icon: app.$getThemeStyle(['color-102'])
	  			}
	  		}]
	  },
    },
    created() {
      this.$em = app.$em
    },
    onLoad() {
		//this.helloMixin()
	},
    methods: {
		delAction(item){
			this.$refs['em-confirm-popup'].open({
				title:"删除提示",
				cancelText:"取消",
				content:"删除后不可恢复，确定要删除吗？",
				confirm:()=>{
					uni.$http.post("/api/circle/delete",{id:item.id}).then(res=>{
						uni.showToast({
							icon:'none',
							title: '已删除',
							duration: 2000
						});
						this.onpPublished()
					})
					.catch(err=>{
								  
					})
				}
			})
		},
		onpPublished(){
			//alert(11)
			this.params1.time = new Date().getTime()
		},
		open(item){
			wx.navigateToMiniProgram({
			  appId:item.appId,
			  path: item.path,
			  // '你要跳转的小程序的版本（trial/develop/release）'
			  envVersion:"release",
			  success(res) {
			    console.log(res)
			  },
			  fail(res) {
			    console.log(res)
			  }
			})
		},
		push(){
			 app.$navigateTo(`/pages/circle/push`)
		},
		clickHeaderBtn(e) {
		  if (e.position === 'left' && e.index === 0) {
			app.$navigateBack()
		  }
		},
	}
  }
</script>

<style>
  .header {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    z-index: 101;
  }

  .scroller {
    position: absolute !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
  }
  @keyframes zoom {
    0% {
      transform: scale(0.5);
    }
    50% {
      transform: scale(1.1);
    }
    100% {
      transform: scale(1);
    }
  }
  .liked-scale-animation {
    animation: zoom 0.5s ease-in-out;
  }
 
</style>
